package com.zcf.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.zcf.pojo.UserRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ZhaoQi
 * @since 2019-06-15
 */
@Mapper
@Transactional(rollbackFor = Exception.class)
public interface UserRecordMapper extends BaseMapper<UserRecord> {


    @Select("select create_time as createTime,wximg,nickname,userid,roomid,room_grade as roomGrade,game_type as gameType,sum_winnumber as sumWinnumber,uuid from user_record where userid = #{userid} and game_type = #{type} order by create_time desc limit #{tiao}")
    List<UserRecord> userRecordList(@Param("userid") Long userid,@Param("type")Integer type, @Param("tiao")int tiao);

    @Select("select create_time as createTime,wximg,nickname,userid,roomid,room_grade as roomGrade,game_type as gameType,sum_winnumber as sumWinnumber,uuid from user_record where  create_time between #{startTime}  and #{endTime}")
    List<UserRecord> selectByExample(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    @Select("select create_time as createTime,wximg,nickname,userid,roomid,room_grade as roomGrade,game_type as gameType,sum_winnumber as sumWinnumber,uuid from user_record where  create_time between #{startTime}  and #{endTime} and userid = #{userid}")
    List<UserRecord> userSum(@Param("userid") Long userid,@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}
